package com.seh.contentcenter.controller;

import com.seh.contentcenter.domain.Result;
import com.seh.contentcenter.dto.ReplyDTO;
import com.seh.contentcenter.service.ReplyService;
import com.seh.contentcenter.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/reply")
public class ReplyController {

    @Autowired
    private ReplyService replyService;

    /**
     * 查找某一楼的所有回复（不包含楼主）
     *
     * @param kid
     * @param currentPage
     * @return
     */
    @GetMapping("/findReplyById")
    public List<ReplyDTO> getRepliesByCommentId(@RequestParam("kid") Integer kid,
                                                @RequestParam("currentPage") Integer currentPage) {
        return replyService.getRepliesByCommentId(kid, currentPage);
    }

    /**
     * 新增评论--回复楼主
     *
     * @param kid
     * @param replyName
     * @param replyContent
     * @param pid
     * @param userId
     * @return
     */
    @GetMapping("/insertReply")
    public String insertReply(@RequestParam("kid") Integer kid, @RequestParam("replyName") String replyName,
                              @RequestParam("replyContent") String replyContent, @RequestParam("pid") Integer pid,
                              @RequestParam("userId") Integer userId) {
        return replyService.insertReply(kid, replyName, replyContent, pid, userId);
    }

}
